#!/bin/bash

IFS_OLD=$IFS
IFS=$'\n'
SERVERS="usc|hall|room"

for var in $(ps -u $(basename $HOME) | grep -E $SERVERS)
do
	pid=$(echo $var | awk '{print $1}')
	pname=$(echo $var | awk '{print $4}')

	if kill $pid
	then 
		echo "$pname stoped"
	else
		echo "$pname can't be stoped"
	fi
done

IFS=$IFS_OLD

cond=$(ps -u $(basename $HOME) | grep -E $SERVERS | wc -l)
while [ $cond -gt 0 ]
do
	sleep 1
	cond=$(ps -u $(basename $HOME) | grep -E $SERVERS | wc -l)
	echo "ServerNum:$cond"
done
